<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>在岗学生</title>
    <!-- 引入element-ui样式 -->
    <link rel="stylesheet" href="../../../plugins/element-ui/index.css">

    <!--    上传图片样式-->
    <style>
        .avatar-uploader .el-upload {
            border: 1px dashed #d9d9d9;
            border-radius: 6px;
            cursor: pointer;
            position: relative;
            overflow: hidden;
        }
        .avatar-uploader .el-upload:hover {
            border-color: #409EFF;
        }
        .avatar-uploader-icon {
            font-size: 28px;
            color: #8c939d;
            width: 178px;
            height: 178px;
            line-height: 178px;
            text-align: center;
        }
        .avatar {
            width: 178px;
            height: 178px;
            display: block;
        }
    </style>
</head>
<body>

<div id="app">
    <el-container style="height: 800px; border: 1px solid #eee">
        <el-container>
            <div style="width: 100%;position: relative">

                <div style=";margin-bottom: 80px;">
                    <el-input
                            placeholder="请输入岗位名称"
                            clearable
                            style="width: 20%; "
                            prefix-icon="el-icon-search"
                            v-model="Query.jobName"
                    >
                    </el-input>
                    <el-button @click="getAll()" class="dalfBut">查询</el-button>

                </div>

                <template>
                    <el-table :data="dataList" border style="width: 100%">
                        <el-table-column  prop="jobName" label="岗位名称"   align="center"></el-table-column>
                        <el-table-column prop="stuNumber" label="学号"    align="center"></el-table-column>

                        <el-table-column prop="name" label="学生姓名"    align="center"></el-table-column>


                        <el-table-column prop="workTime" label="工时"   align="center"></el-table-column>

                        <el-table-column prop="salary" label="时薪"   align="center"></el-table-column>

                        <el-table-column prop="total" label="总薪水"   align="center"></el-table-column>

                        <el-table-column prop="salaryGive" label="发放状态"   align="center">
                            <div slot-scope="{ row }">
                                <h1 v-if="row.salaryGive=='true'"  style="color: green">已发放</h1>
                                <h1 v-else-if="row.salaryGive=='false'" style="color: red">未发放</h1>
                            </div>
                        </el-table-column>

                        <el-table-column label="操作"   align="center">
                            <template slot-scope="scope">
                                <el-button @click="salaryGive(scope.row)" type="text" size="small">发放工资</el-button>
                            </template>
                        </el-table-column>

                    </el-table>
                </template>

                
                <!--分页组件-->
                <el-pagination
                        class="pagination"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>

            </div>
        </el-container>
    </el-container>
</div>


<script src="../../../plugins/vue/vue.js"></script>

<!-- 引入element-ui组件库 -->
<script src="../../../plugins/element-ui/index.js"></script>

<!-- 引入axios -->
<script src="../../../plugins/axios/axios.min.js"></script>

<script>

    new Vue({
        data:{

            recruitmentInfo:{}, //当前用户信息

            hello:'hello222',
            //搜索内容
            Query:{
                jobName:""
            },

            //修改弹框内容
            formData_update:{
                image:'',
            },
            dialog_update:false,


            //显示的数据
            dataList:[],

            //element-ui分页插件
            pagination: {//分页相关模型数据 1
                currentPage: 1,//当前页码1
                pageSize:5,//每页显示的记录数1
                total:0,//总记录数1
            },


        },
        el:'#app',    //element
        created() {
            const recruitmentInfo = window.localStorage.getItem('recruitment')
            console.log("recruitmentInfo1:::"+recruitmentInfo)
            if (recruitmentInfo) {
                this.recruitmentInfo = JSON.parse(recruitmentInfo)
            }
            console.log("recruitmentInfo2:::"+recruitmentInfo)


            this.getAll();
        },
        methods: {

            getAll() {
                parent = "?jobName=" + this.Query.jobName+"&commercialId="+this.recruitmentInfo.data.id+"&statusApplication=true";
                axios.get("/postApplications/getPagePostApplication/" + this.pagination.currentPage + "/" + this.pagination.pageSize +'/1'+ parent).then((res) => {
                    console.log(res)
                    this.dataList = res.data.data.records
                    this.pagination.total = res.data.data.total
                    this.Query.jobName = ""
                })
            },

            //切换页码
            handleCurrentChange(currentPage) {
                console.log("切换页码:")
                this.pagination.currentPage = currentPage;
                console.log(currentPage)
                this.getAll();
            },

            //发放工资
            salaryGive(row){
                console.log(row)
                if (row.salaryGive=='true'){
                    this.$message.info("工资已发放！")
                }else if (row.workTime=='0'){
                    this.$message.info("请先录入工时！")
                }else {
                    this.$confirm("确定发放当前工资?","提醒",{type: 'info'
                    }).then(()=>{
                        console.log("row::")
                        row.salaryGive=true
                        console.log(row)
                        axios.put("/postApplications/updatePostApplication",row).then((res)=>{

                            if (res.data.code){
                                this.$message.success(res.data.msg)
                            }else{
                                this.$message.error(res.data.msg)
                            }
                        }).finally(()=>{
                            this.getAll()
                        })
                    }).catch(()=>{
                        //取消删除
                        this.$message.info("取消删除操作")
                    })
                }
            },

        }
    })

</script>
</body>
</html>




